#!/usr/bin/python
# -*- coding: utf-8 -*-


# a = 'hello world'
# b = "abcdefg"
# print(type(a))
# print(type(b))
#
# #字符串输出
# print('hello world')
# name = 'Tom'
# print('名字%s'%name)
# print(f'名字是{name}')

#下标
# name = "abcdef"
#
# print(name[1])
# print(name[0])
# print(name[2])

#切片
# name = "abcdefg"
#
# print(name[2:5:1])
# print(name[2:5])
# print(name[:5])
# print(name[1:])
# print(name[:])
# print(name[::2])
# print(name[:-1])
# print(name[-4:-1])
# print(name[::-1])

#查找find
mystr = "hello world and superctest and chaoge and Python"


# print(mystr.find('and'))
# print(mystr.find('and', 15, 30))
# print(mystr.find('ands'))

#检查index
# print(mystr.index('and'))
# print(mystr.index('and', 15, 30))
# print(mystr.index('ands'))


#统计count
# print(mystr.count('and'))
# print(mystr.count('and', 15, 30))
# print(mystr.count('ands'))

#替换replace
# print(mystr.replace('and', 'is'))
# print(mystr.replace('and', 'is', 1))
# print(mystr.replace('is', 'and'))

#分割split
# print(mystr.split(' ', 1))
# print(mystr.split(' '))
# print(mystr.split('and'))


#组合join
list1 = ['chao', 'ge', 'test', 'promotion']
t1 = ('aa', 'b', 'cc', 'ddd')

# print('_'.join(list1))
# print('.......'.join(t1))

#将字符串第一个字符转换成大写capitalize
# print(mystr.capitalize())

#将字符串里的单词没个首字母转换成大写title
# print(mystr.title())

#将字符串中大写转换成小写lower
# print(mystr.lower())

#将字符串中小写转换成大写upper
# print(mystr.upper())

#删除字符串两侧空格strip
# print(mystr.strip())

# #左对齐ljust
# print(mystr.ljust(2, ' '))
# #右对齐rjust
# print(mystr.rjust(2, ' '))
# #居中对齐center
# print(mystr.center(1, ' '))
mystr = "hello world and supertest and chaoge and Python "
# #判断startswith
# print(mystr.startswith('hello'))
# print(mystr.startswith('hello', 5, 10))
#
# #结尾endswith
# print(mystr.endswith(' '))
# print(mystr.endswith(' ', 5, 10))

# mystr1 = 'hello'
# mystr2 = 'hello12345'

#字符串都是由字母，且最少有一个字母，返回true
# print(mystr1.isalpha())
# print(mystr2.isalpha())

#字符串中只包含数字返回true
# mystr1 = 'aaa12345'
# # mystr2 = '12345'
# #
# # print(mystr1.isdigit())
# # print(mystr2.isdigit())

#字符串不为空，且有字母和数字组成的返回true
# mystr1 = 'aaa12345'
# mystr2 = '12345-'
# print(mystr1.isalnum())
# print(mystr2.isalnum())


#字符串中只包含空白返回true
mystr1 = '1 2 3 4 5'
mystr2 = ' '

print(mystr1.isspace())
print(mystr2.isspace())



